﻿//-------------------------------------------------------------------
//	Copyright (c) 2010-2014  Zhirnov Andrey
//	This file is part of the "UX Standard Lib" project.
//	See copyright notice in "UX_Logger.h".
//-------------------------------------------------------------------

#ifndef _UXS_LOG_FILE_OUTPUT_H
#define _UXS_LOG_FILE_OUTPUT_H

#pragma once

#include "ILogger.h"
//#include "../../filesystem/ux_filesystem.h"

namespace UX_STL
{
namespace UXLogger
{

	//
	// Txt Log File Output
	//

	class UX_EXPORT CTxtLogOutput : public ILogOutput
	{
	private:
		WFilePtr		_pFile;
		
	private:
		void _AddPrefix(string &str, e_log_msg::type ePrefix);
		void _Flush(const string &s);

	public:
		CTxtLogOutput(WFilePtr pFile);
		~CTxtLogOutput();

		// ILogOutput //
		virtual void Write(const char *pMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine);
		virtual void NewLine();
		virtual void Free();
		virtual e_log_output::bits	GetTypeBits() const		{ return e_log_output::LOG_FILE_BIT; }
	};



	//
	// Html Log File Output
	//

	class UX_EXPORT CHtmlLogOutput : public ILogOutput
	{
	private:
		WFilePtr		_pFile;
		atomic_uint32	_uCurColor;
		
	private:
		void _SetColor(uint uColor, string &str);
		void _Flush(const string &s);

	public:
		CHtmlLogOutput(WFilePtr pFile);
		~CHtmlLogOutput();

		// ILogOutput //
		virtual void Write(const char *pMsg, e_log_msg::type eType, const char *pSrcFile, uint uLine);
		virtual void NewLine();
		virtual void Free();
		virtual e_log_output::bits	GetTypeBits() const		{ return e_log_output::LOG_FILE_BIT; }
	};

//-------------------------------------------------------------------

}	// UXLogger
}	// UX_STL

#endif	// _UXS_LOG_FILE_OUTPUT_H